{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\陆宁\\AppData\\Local\\Temp\\ipykernel_20656\\3391021421.py:32: DeprecationWarning: 'exec_' will be removed in the future. Use 'exec' instead.\n",
      "  sys.exit(app.exec_())\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello Write my name here\n",
      "Hello 分爱无法完\n"
     ]
    },
    {
     "ename": "SystemExit",
     "evalue": "0",
     "output_type": "error",
     "traceback": [
      "An exception has occurred, use %tb to see the full traceback.\n",
      "\u001b[1;31mSystemExit\u001b[0m\u001b[1;31m:\u001b[0m 0\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "d:\\WorkAPP\\Anaconda\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3468: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n",
      "  warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "from PySide6.QtWidgets import (QLineEdit, QPushButton, QApplication,\n",
    "    QVBoxLayout, QDialog)\n",
    "\n",
    "class Form(QDialog):\n",
    "\n",
    "    def __init__(self, parent=None):\n",
    "        super(Form, self).__init__(parent)\n",
    "        # 创建组件\n",
    "        self.edit = QLineEdit(\"Write my name here\")\n",
    "        self.button = QPushButton(\"Show Greetings\")\n",
    "        # 创建布局并添加组件\n",
    "        layout = QVBoxLayout()\n",
    "        layout.addWidget(self.edit)\n",
    "        layout.addWidget(self.button)\n",
    "        # 应用布局\n",
    "        self.setLayout(layout)\n",
    "        # 连接greetings槽和按钮单击信号\n",
    "        self.button.clicked.connect(self.greetings)\n",
    "\n",
    "    # 向用户打招呼\n",
    "    def greetings(self):\n",
    "        print(f\"Hello {self.edit.text()}\")\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    # 创建Qt应用程序\n",
    "    app = QApplication(sys.argv)\n",
    "    # 创建并显示Form\n",
    "    form = Form()\n",
    "    form.show()\n",
    "    # 运行Qt主循环\n",
    "    sys.exit(app.exec_())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import yaml\n",
    "data ={\"SVN\":\"hello\", \"name\":\"123\"}\n",
    "with open('settings.yaml',\"w+\") as f:\n",
    "    yaml.dump(data,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:/study/Books\\SD5868FS文档删减版_10.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_11.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_12.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_13.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_14.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_15.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_16.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_17.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_18.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_19.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_2.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_21.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_3.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_4.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_5.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_6.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_7.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_8.docx\n",
      "D:/study/Books\\SD5868FS文档删减版_9.docx\n",
      "D:/study/Books\\~$5868FS文档删减版_8.docx\n"
     ]
    }
   ],
   "source": [
    "import glob\n",
    "path = \"D:/study/Books\"\n",
    "\n",
    "data = glob.iglob(path + '\\*.docx')\n",
    "for i in data:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "D:/projects/comShare\\l00806702.db\n"
     ]
    }
   ],
   "source": [
    "import glob\n",
    "path = 'D:/projects/comShare/*.db'\n",
    "dfFile = glob.glob(path)\n",
    "for i in dfFile:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sqlite3\n",
    "conn = sqlite3.connect(\"D:/projects/comShare\\l00806702.db\")\n",
    "cursor = conn.cursor()\n",
    "# cursor.execute(\"DROP TABLE dune\")\n",
    "# cursor.execute(\"show tables\")\n",
    "\n",
    "cursor.execute(\"\"\"create table if not exists dune(\n",
    "    test interger, \n",
    "    testdune TEXT)\"\"\")\n",
    "conn.commit()\n",
    "cursor.execute(\"\"\"INSERT INTO dune VALUES(?,?)\"\"\", (1, \"dunetest\"))\n",
    "conn.commit()\n",
    "cursor.close()\n",
    "conn.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "conn = sqlite3.connect(\"data.db\")\n",
    "cur = conn.cursor()\n",
    "cur.execute(\"\"\"CREATE TABLE IF NOT EXISTS products (\n",
    "    item TEXT,\n",
    "    count INTEGER,\n",
    "    price REAL)\"\"\")\n",
    "conn.commit()\n",
    "with conn:\n",
    "    item = \"pen\"\n",
    "    count = 10\n",
    "    price = 5\n",
    "    cur.execute(\"\"\"INSERT INTO products VALUES (?,?,?)\"\"\", (item, count, price))\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 'dunetest')\n",
      "[(1, 'dunetest'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test'), (2, '2test')]\n",
      "(10,)\n"
     ]
    }
   ],
   "source": [
    "# conn = sqlite3.connect(\"D:/projects/comShare\\l00806702.db\")\n",
    "# cursor = conn.cursor()\n",
    "# cursor.execute(\"SELECT count(*) from dune where test=?\", (1,))\n",
    "data = cursor.execute(\"SELECT * from dune\")\n",
    "print(data.fetchone())\n",
    "cursor.execute(\"insert into dune values(?,?)\", (2, \"2test\"))\n",
    "# conn.commit()\n",
    "data = cursor.execute(\"select * from dune\")\n",
    "print(data.fetchall())\n",
    "data = cursor.execute(\"select count(test) from dune where testdune=?\", (\"2test\",))\n",
    "print(data.fetchone())\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, 'fejiwfjjaf'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test'),\n",
       " (2, '2test')]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cursor.execute(\"UPDATE dune SET testdune=? where test=?\",(\"fejiwfjjaf\", 1))\n",
    "data = cursor.execute(\"select * from dune\")\n",
    "data.fetchall()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "ename": "OperationalError",
     "evalue": "database is locked",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mOperationalError\u001b[0m                          Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[11], line 4\u001b[0m\n\u001b[0;32m      2\u001b[0m conn \u001b[39m=\u001b[39msqlite3\u001b[39m.\u001b[39mconnect(\u001b[39m\"\u001b[39m\u001b[39ml00806702.db\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m      3\u001b[0m cursor \u001b[39m=\u001b[39m conn\u001b[39m.\u001b[39mcursor()\n\u001b[1;32m----> 4\u001b[0m cursor\u001b[39m.\u001b[39;49mexecute(\u001b[39m\"\u001b[39;49m\u001b[39mdrop  table duneComShare\u001b[39;49m\u001b[39m\"\u001b[39;49m)\n\u001b[0;32m      5\u001b[0m CreatTableCreatSql \u001b[39m=\u001b[39m \u001b[39m\"\"\"\u001b[39m\u001b[39mCREATE TABLE IF NOT EXISTS duneComShare (\u001b[39m\n\u001b[0;32m      6\u001b[0m \u001b[39mkeyword TEXT,\u001b[39m\n\u001b[0;32m      7\u001b[0m \u001b[39mdescribe TEXT\u001b[39m\n\u001b[0;32m      8\u001b[0m \u001b[39mdata TEXT)\u001b[39m\u001b[39m\"\"\"\u001b[39m\n\u001b[0;32m      9\u001b[0m cursor\u001b[39m.\u001b[39mexecute(CreatTableCreatSql)\n",
      "\u001b[1;31mOperationalError\u001b[0m: database is locked"
     ]
    }
   ],
   "source": [
    "import sqlite3\n",
    "conn =sqlite3.connect(\"l00806702.db\")\n",
    "cursor = conn.cursor()\n",
    "cursor.execute(\"drop  table duneComShare\")\n",
    "CreatTableCreatSql = \"\"\"CREATE TABLE IF NOT EXISTS duneComShare (\n",
    "keyword TEXT,\n",
    "describe TEXT\n",
    "data TEXT)\"\"\"\n",
    "cursor.execute(CreatTableCreatSql)\n",
    "data = cursor.execute(\"select * from duneComShare\")\n",
    "print(data.fetchone())\n",
    "# data = cursor.execute(\"SELECT * FROM duneComShare WHERE keyword LIKE ?\", ( \"测\",))\n",
    "# print(data.fetchall())\n",
    "data = cursor.execute(\"select * from duneComShare WHERE \")\n",
    "print(data.fetchone())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20230619213100\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "230619213100"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from time import strftime\n",
    "\n",
    "print(strftime(\"%Y%m%d%H%M%S\"))\n",
    "a = strftime(\"%Y%m%d%H%M%S\")[2:]\n",
    "int(a)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
